package com.jxs.android.cmcc;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.jxs.android.util.KeyboardUtil;
import com.jxs.android.util.SmsUtils;
import com.jxs.android.util.StringUtils;
import com.jxs.android.weiget.PopMsg;
import com.jxs.android.weiget.TopBar;

public class ShareApp extends AbstractActivity {
	private EditText invite_friend_number;
	private EditText invite_friend_name;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		initTopBar(savedInstanceState, R.layout.bu_sys_more_invite_friend);
		initLayouts();
	}

	private void initLayouts() {
		invite_friend_number = (EditText) findViewById(R.id.invite_friend_number);
		invite_friend_name = (EditText) findViewById(R.id.invite_friend_name);
	}

	@Override
	public void topBarLogic(TopBar topBar) {
		super.topBarLogic(topBar);
		topBar.hindBtn();
		initTopBarReturn(topBar);
		topBar.setTitle("分享软件");

	}

	public void inviteSumbit(View view) {
		if (StringUtils.isEmpety(invite_friend_number.getText().toString())) {
			PopMsg.show(R.string.error_not_input_invite_number);
		} else {
			SmsUtils.sendSMS4Invite(this, invite_friend_name.getText().toString(), invite_friend_number.getText().toString());
			new AlertDialog.Builder(this).setTitle(R.string.prompt_tip).setMessage(R.string.bu_more_invite_sms_succuss)
					.setPositiveButton(R.string.prompt_cancel, new DialogInterface.OnClickListener() {

						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.cancel();
						}
					}).setNegativeButton(R.string.prompt_confirm, new DialogInterface.OnClickListener() {

						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.cancel();
							finish();
						}
					}).show();
		}
	}

	@Override
	protected void onPause() {
		KeyboardUtil.hideSoftKeyBoard(this);
		super.onPause();
	}
}